
viewer = new Cesium.Viewer('cesiumContainer',{
    skyBox : false,
    skyAtmosphere : false,
    baseLayerPicker : false,
    //shouldAnimate : true
});

var canvas = viewer.canvas;
canvas.setAttribute('tabindex', '0'); // needed to put focus on the canvas
canvas.onclick = function() {
    canvas.focus();
};

var scene = viewer.scene;
var ellipsoid = viewer.scene.globe.ellipsoid; 
scene.imageryLayers.removeAll(true);
scene.globe.baseColor = new Cesium.Color(0.0, 0.0, 0.0,0.0); // 没有影像时地球的基础颜色，默认为蓝色
scene.globe.enableLighting=false;
scene.globe.depthTestAgainstTerrain=false;
scene.globe.showGroundAtmosphere=false;

$(".cesium-viewer-toolbar,.cesium-viewer-animationContainer,.cesium-viewer-timelineContainer,.cesium-viewer-bottom").css("display","none");
$(".cesium-viewer-fullscreenContainer .cesium-button").css("background","#000");

for(var i=0;i<jsonArray.length;i++){
	var color = jsonArray[i].color.split(":");
	 addEllipses(jsonArray[i].name,jsonArray[i].data,Cesium.Color.fromBytes(color[0],color[1],color[2],color[3]))
	/*if(jsonArray[i].type == "water"){
		 addEllipses(jsonArray[i].name,jsonArray[i].data,Cesium.Color.fromBytes(0, 200, 255, 150))
	}
	else if(jsonArray[i].type == "coal"){
		addEllipses(jsonArray[i].name,jsonArray[i].data,Cesium.Color.fromBytes(150, 150, 150, 150))
	}
	else if(jsonArray[i].type == "rock"){
		addEllipses(jsonArray[i].name,jsonArray[i].data,Cesium.Color.fromBytes(155, 128, 57, 150))
	}*/
}



function addEllipse(i,data,color){
    viewer.entities.add({
        name : i,
        position : Cesium.Cartesian3.fromDegrees(-110.0, 35.0,30000.0 + data[0] * 100),
        ellipse : {
            semiMinorAxis : 1000.0,
            semiMajorAxis : 1000.0,
            height : 30000.0 + data[0] * 100,
            extrudedHeight : 30000.0 + data[1] * 100,
            material : color
        }
        
    });
}

function addEllipses(i,data,color){
    viewer.entities.add({
        name : i,
        polylineVolume : {
            positions : Cesium.Cartesian3.fromDegreesArrayHeights([ -110.02 + (0.04/max)*data[0], 35.0, 30000000,
                                                                    -110.02 + (0.04/max)*data[1], 35.0, 30000000]),
            shape : computeCircle(2000.0),
            material : color
        }       
    });
}

function computeCircle(radius) {
    var positions = [];
    for (var i = 0; i < 360; i++) {
        var radians = Cesium.Math.toRadians(i);
        positions.push(new Cesium.Cartesian2(radius * Math.cos(radians), radius * Math.sin(radians)));
    }
    return positions;
}

//viewer.zoomTo(viewer.entities);


viewer.camera.lookAt(Cesium.Cartesian3.fromDegrees(-110.0, 35.0,30005000), new Cesium.Cartesian3(0, -30000, 30000));


viewer.cesiumWidget.screenSpaceEventHandler.removeInputAction(Cesium.ScreenSpaceEventType.LEFT_DOUBLE_CLICK);//屏蔽双击事件
viewer.cesiumWidget.screenSpaceEventHandler.removeInputAction(Cesium.ScreenSpaceEventType.LEFT_CLICK);//屏蔽单击事件


//scene.screenSpaceCameraController.enableZoom = false;

